import Home from '@/views/Home'
import Search from '@/views/Search'
import NotFound from '@/views/NotFound'
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const router = new VueRouter({
  // mode: history,
  routes: [
    //路由重定向,页面刚打开的时候
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      component: Home
    },
    // ? 问号表示可选参数 传不传参数都可以匹配到这条路由规则
    {
      name:'search',
      path: '/search/:words?',
      component: Search
    },

    //路由末尾配置添加 * 来设置 404页面组件
    {
      path: '*',
      component: NotFound
    }
  ]
})

export default router